<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    #small {
      position: absolute;
      left: 100px;
      top: 100px;
      width: 300px;
      height: 560px;
    }

    #small img {
      width: 100%;
      height: 100%;
    }

    #mask {
      position: absolute;
      left: 0;
      top: 0;
      display: none;
      width: 150px;
      height: 150px;
      background-color: #fff;
      opacity: .5;
    }

    #big {
      position: absolute;
      left: 500px;
      top: 100px;
      display: none;
      overflow: hidden;
      width: 450px;
      height: 450px;
      border: 1px solid #000;
    }

    #big img {
      position: absolute;
      left: 0;
      top: 0;
      width: 900px;
      height: 1680px;
    }
  </style>
</head>

<body>
  <div id="small">
    <img src="./timg.jpeg" alt="">
    <div id="mask"></div>
  </div>

  <div id="big">
    <img src="./timg.jpeg" alt="">
  </div>

  <script>
    var oSmall = document.getElementById("small")
    var oBig = document.getElementById("big")
    var oMask = document.getElementById("mask")
    var oBigImg = oBig.getElementsByTagName("img")[0]

    oSmall.onmouseover = function() {
      oMask.style.display = "block"
      oBig.style.display = "block"
    }

    oSmall.onmouseout = function() {
      oMask.style.display = "none"
      oBig.style.display = "none"
    }

    oSmall.onmousemove = function(ev) {
      var e = ev || window.event
      var l = e.clientX - oSmall.offsetLeft - 75
      var t = e.clientY - oSmall.offsetTop - 75

      if (l <= 0) {
        l = 0
      }
      if (l >= 150) {
        l = 150
      }
      if (t <= 0) {
        t = 0
      }
      if (t >= 410) {
        t = 410
      }
      oMask.style.left = l + "px"
      oMask.style.top = t + "px"

      oBigImg.style.left = l * -3 + "px"
      oBigImg.style.top = t * -3 + "px"
    }
  </script>
</body>

</html>